/**
 * 
 */
package com.py.credit.service;

import java.util.List;
import java.util.Map;

import com.py.credit.entity.Column;

/**
 * @author dd
 *
 */
public interface DataRelateService {

	/**
	 * @param datasourceId
	 * @return
	 */
	List<String> getAssociationMetricCodesByDbId(int datasourceId);

	/**
	 * @param datasourceId
	 * @return
	 */
	List<String> getMajorMetricCodesByDbId(int datasourceId);

	/**
	 * @param tableName
	 * @param batchId
	 * @param majorMetricCodes
	 * @param batchCount
	 * @return
	 */
	List<Map<String, Object>> getRecordsByTableName(String tableName, String batchId, List<String> majorMetricCodes,
			int limit);

	/**
	 * @param datasourceId
	 * @param associationMetricCodes
	 * @param record
	 * @return
	 */
	Map<String, String> getMatchZooUnique(int datasourceId, List<String> associationMetricCodes,
			Map<String, Object> record);

	/**
	 * @param datasourceId
	 * @param tybm
	 * @return
	 */
	Map<String, String> getUniqueValue(int datasourceId, String tybm);

	/**
	 * @param datasourceId
	 * @param tybm
	 * @param fillBackData
	 */
	void updateZooUnique(int datasourceId, String tybm, Map<String, String> fillBackData);

	/**
	 * @param recordId
	 * @param tableName
	 */
	void unableAuth(int recordId, String tableName);

	/**
	 * @param tableName
	 * @param recordId
	 * @param tybm
	 */
	void updateRecord(String tableName, int recordId, String tybm);

	/**
	 * @param resourceId
	 * @param tybm
	 */
	void addTybmCube(String resourceId, String tybm);

	/**
	 * @param dbId
	 * @param majorMetricCodes
	 * @param record
	 * @return
	 */
	boolean majorMatchZooUniques(int dbId, List<String> majorMetricCodes, Map<String, Object> record);

	/**
	 * @param record
	 * @param tableId
	 * @param majorMetricCodes
	 * @param rootId
	 * @param deptId
	 */
	void addZooRecord(Map<String, Object> record, int tableId, List<String> majorMetricCodes, int rootId, int deptId);

	/**
	 * @param tybm
	 * @param record
	 * @param tableId
	 * @param majorMetricCodes
	 */
	void addZooUnique(String tybm, Map<String, Object> record, int dbId, List<String> majorMetricCodes);

	int getUnableAuthZooRecord();

	/**
	 * @param resourceId
	 * @param tybm
	 * @return
	 */
	boolean exist(String resourceId, String tybm);

	/**
	 * @param datasourceId
	 * @return
	 */
	List<String> getCommonMetricCodesByDbId(int datasourceId);

	/**
	 * @param qymc
	 * @return
	 */
	Integer getConcernedSubjectId(String qymc);

	boolean existAssociationMetricCodes(List<Column> tableColumns, List<String> associationMetricCodes);

	boolean needAssociation(Map<String, Object> record, Map<String, String> uniqueValue, List<String> commonMetricCodes,
			Map<String, String> fillBackData);

	/**
	 *
	 * @param tableId
	 *            表id
	 * @param kId
	 *            库id
	 * @param record
	 *            数据
	 * @param deptId
	 *            数据归属部门id
	 * @return Map<String, String> 错误信息 {message:"XXX"}
	 */
	Map<String, String> relatePerform(int tableId, int kId, Map<String, Object> record, int deptId);

	Integer batchRelatePerform(String batchId, String tableName, String datasourceId, String tableId, String deptId);

	int getWaitCountByBatchId(String tableName, String batchId);

	void addDummyZooUniqueIfNoData(int datasourceId);

	void deleteDummyZooUnique(int datasourceId);

}
